Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix hermes tool parser output error stream arguments in some cases (#10395) #10398

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

xiyuan-lee
Copy link
Contributor

@xiyuan-lee xiyuan-lee commented Nov 16, 2024

[BugFix] Fix hermes tool parser output error stream arguments in some cases (#10395)

Use delta_text to return directly to the user, preventing errors caused by partial_json_parser during the incremental computation of parameters.

FIX #9693
FIX #9908
FIX #10395

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@mergify mergify bot added the frontend label Nov 16, 2024
@DarkLight1337
Copy link
Member

cc @K-Mistele

@xiyuan-lee
Copy link
Contributor Author

xiyuan-lee commented Nov 17, 2024

The function partial_json_parser will complete the partrial JSON string {"name": "tool_name", "arguments": {"arg1": " to {"name": "tool_name", "arguments": {"arg1": ""}}, which will result in an error when calculating the incremental changes in the arguments field.

@githebs
Copy link

githebs commented Nov 17, 2024

Thanks everyone for making this potential fix!
I'll try on my own examples as soon as tomorrow
In the spirit of testing on the same basis, is it possible to have a minimal a very minimal python codebase requesting vllm with tools and streaming ?

@xiyuan-lee
Copy link
Contributor Author

Thanks everyone for making this potential fix! I'll try on my own examples as soon as tomorrow In the spirit of testing on the same basis, is it possible to have a minimal a very minimal python codebase requesting vllm with tools and streaming ?

For the relevant code, please refer to the following link: #10395

@githebs
Copy link

githebs commented Nov 17, 2024

Thanks everyone for making this potential fix! I'll try on my own examples as soon as tomorrow In the spirit of testing on the same basis, is it possible to have a minimal a very minimal python codebase requesting vllm with tools and streaming ?

For the relevant code, please refer to the following link: #10395

Totally missed that, thanks a lot!

@DarkLight1337
Copy link
Member

Please fix the linter errors.

@DarkLight1337
Copy link
Member

DarkLight1337 commented Nov 19, 2024

Don't worry about DCO, we can pass it manually if you agree to it.

@xiyuan-lee
Copy link
Contributor Author

Please fix the linter errors.

I've fixed the linter errors.

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) November 19, 2024 10:24
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 19, 2024
@DarkLight1337 DarkLight1337 merged commit f028dff into vllm-project:main Nov 19, 2024
62 checks passed
coolkp pushed a commit to coolkp/vllm that referenced this pull request Nov 20, 2024
KuntaiDu pushed a commit to KuntaiDu/vllm that referenced this pull request Nov 20, 2024
mfournioux pushed a commit to mfournioux/vllm that referenced this pull request Nov 20, 2024
rickyyx pushed a commit to rickyyx/vllm that referenced this pull request Nov 20, 2024
@Sala8888
Copy link

Sala8888 commented Nov 22, 2024

I used the hermes_tool_parser.py as tool-parser-plugin and registered the parser as hermes_patched, but still have the same problem.

Traceback (most recent call last):
  File "/app/hermes_tool_parser.py", line 228, in extract_tool_calls_streaming
    function_name: Union[str, None] = current_tool_call.get("name")
                                      ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Error trying to handle streaming tool call.
Traceback (most recent call last):
  File "/app/hermes_tool_parser.py", line 292, in extract_tool_calls_streaming
    args_delta_start_loc = cur_arguments_json.index(delta_text) \
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: substring not found

Here is how I start vllm service:

python3 -m vllm.entrypoints.openai.api_server \
--model /app/Qwen2.5-72B-Instruct-AWQ \
--port 7415 \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.95 \
--max-model-len 64000 \
--enforce-eager \
--disable_custom_all_reduce \
--enable-auto-tool-choice \
--tool-parser-plugin /app/hermes_tool_parser.py \
--tool-call-parser hermes_patched  \
--chat-template /app/qwen.jinja

tlrmchlsmth pushed a commit to neuralmagic/vllm that referenced this pull request Nov 23, 2024
@xiyuan-lee
Copy link
Contributor Author

xiyuan-lee commented Nov 23, 2024

I used the hermes_tool_parser.py as tool-parser-plugin and registered the parser as hermes_patched, but still have the same problem.

Traceback (most recent call last):
  File "/app/hermes_tool_parser.py", line 228, in extract_tool_calls_streaming
    function_name: Union[str, None] = current_tool_call.get("name")
                                      ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Error trying to handle streaming tool call.
Traceback (most recent call last):
  File "/app/hermes_tool_parser.py", line 292, in extract_tool_calls_streaming
    args_delta_start_loc = cur_arguments_json.index(delta_text) \
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: substring not found

Here is how I start vllm service:

python3 -m vllm.entrypoints.openai.api_server \
--model /app/Qwen2.5-72B-Instruct-AWQ \
--port 7415 \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.95 \
--max-model-len 64000 \
--enforce-eager \
--disable_custom_all_reduce \
--enable-auto-tool-choice \
--tool-parser-plugin /app/hermes_tool_parser.py \
--tool-call-parser hermes_patched  \
--chat-template /app/qwen.jinja

I use vllm0.6.3.post1 docker compose, and entrypoint is:

entrypoint: ["/bin/sh", "-c", "python3 -u -m vllm.entrypoints.openai.api_server --model /data/models/Qwen2.5-72B-Instruct-AWQ --enable-auto-tool-choice --tool-call-parser hermes --tensor-parallel-size 2 --gpu_memory_utilization 0.97 --max_model_len 20000 --max_num_seq 40"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
5 participants